package com.newtouch.avmarketing.order.repo;

import com.newtouch.avmarketing.order.entity.User;
import com.newtouch.avmarketing.order.entity.vo.UserVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRepo extends JpaRepository<User,Integer> {

    @Query(value = "select new com.newtouch.avmarketing.order.entity.vo.UserVo(a.id,a.username,a.password,b.orderTime) " +
            "from User a join Orders b on a.id = b.userId where a.id = ?1")
    List<UserVo> findAllByHQL(Integer id);
}
